package com.fudan.backend.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fudan.backend.pojo.statics.CommodityStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Commodity {
    private String commodityId;
    private String storeId;
    private String commodityName;
    private String categoryId;
    private Double price;
    private Integer stocks;
    private List<String> pictures;
    private String description;
    private Integer salesVolume;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date launchDate;
    private Integer status;

    public Commodity(String commodityId, String storeId, String commodityName, String categoryId, Double price, Integer stocks, List<String> pictures, String description) {
        this.commodityId = commodityId;
        this.storeId = storeId;
        this.commodityName = commodityName;
        this.categoryId = categoryId;
        this.price = price;
        this.stocks = stocks;
        this.pictures = pictures;
        this.description = description;
        this.salesVolume = 0;
        this.launchDate = new Date(System.currentTimeMillis());
        this.status = CommodityStatus.ON_SALE;
    }
}
